from torque.torrent.models import OrderedComment as Comment

def getComments(hash):
    try:
        comments = Comment.objects.filter(torrent_id__hash = hash)
    except:
        return []
    else:
        commentList = []
        for comment in comments:
            commentList.append({'id':str(comment.id),'user':str(comment.user_id),'comment':str(comment.comment),'creation':str(comment.creation)})
        
        return commentList

def hasComments(hash):
    try:
        comments = Comment.objects.filter(torrent_id__hash = hash)
    except:
        return 0
    else:
        if len(comments) > 0:
            return 1
        else:
            return 0